package cn.lml.lession.auth.exception;

import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.lml.lession.common.util.Result;



@ControllerAdvice
public class GlobalException {
		
	@ExceptionHandler(CustomException.class)
	@ResponseBody
	public Result getExp0(CustomException ex){
		return Result.error(ex.getMessage());
	}
	
	
	@ExceptionHandler(BindException.class)
	@ResponseBody
	public Result getExp2(BindException ex){
		return Result.error("参数有误").put("details", ex.getMessage());
	}
	
	
	
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Result getExp5(Exception ex){
		ex.printStackTrace();
		return Result.error("未知的异常！");
	}
}
